package com.zcx.merchantorder.util;

import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

/**
 * @Description: 工具类
 * @Author: zcx
 * @CreateDate: 2019/3/3 14:24
 */
public class ToolUtil {

    public static boolean isShouldHideSoftKeyBoard(View view, MotionEvent event) {
        if (view != null && (view instanceof EditText)) {
            int[] l = { 0, 0 };
            view.getLocationInWindow(l);
            int left = l[0], top = l[1], bottom = top +view.getHeight(), right = left
                    + view.getWidth();
            if (event.getX() > left && event.getX() < right
                    && event.getY() > top && event.getY() < bottom) {
                // If click the EditText event ,ignore it
                return false;
            } else {
                return true;
            }
        }
        // if the focus is EditText,ignore it;
        return false;
    }

    /**
    *防止快速点击
     * @date: 2019/3/3 14:47
     * @author: zcx
     * @param 
     * @return boolean
     */
    private boolean fastClick() {
        long lastClick = 0;
        if (System.currentTimeMillis() - lastClick <= 1000) {
            return false;
        }
        lastClick = System.currentTimeMillis();
        return true;
    }
}
